﻿using Microsoft.AspNetCore.Http;

namespace StudentManagementSystem.Common.CustomMiddleWares
{
    public class RequestLoggerMiddleware
    {
        private readonly RequestDelegate _next;
        private readonly string _loggerName;

        public RequestLoggerMiddleware(RequestDelegate next,string loggerName)
        {
            _next = next;
            _loggerName = loggerName;
        }

        public async Task InvokeAsync(HttpContext context)
        {
            Console.WriteLine($"[{_loggerName}] Request: {context.Request.Method} {context.Request.Path}");
            await _next(context);
            Console.WriteLine($"[{_loggerName}] Response: {context.Response.StatusCode}");
        }
    }
}
